<?php

namespace App\Http\Requests\PC\CustomerStore\Product;

use App\Http\Requests\ApiRequest;
use Illuminate\Validation\Rule;

/**
 * @property string asset_id
 * @property string|null detach_exist - 是否先解除之前绑定了对应请求 asset_id 的产品
 * @property array|string[] product_ids
 */
class ProductPatchesAssetRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'asset_id'      => 'required|int|min:0',
            'product_ids'   => 'required|array|min:1',
            'product_ids.*' => 'required|int|min:1',
            'detach_exist'  => 'sometimes|required|in:0,1'
        ];
    }

//    public function messages()
//    {
//        return [
//            'asset_id.*'     => '素材必须',
//
//            'product_ids.*.*' => '产品ID必须合法',
//            'product_ids.*'   => '产品ID必须是数组',
//        ];
//    }
}
